package org.lex.ftp.queue;

public class QueueContainerUtils {
	/**
	 * ����queue��index1��index2��ֵ.<br>
	 * ����index1����index2����Ч����(�������Χ)�������κβ���
	 * 
	 */
	public static <E> void swap(IQueueContainer<E> queue, int index1, int index2) {
		if (false == valid(queue, index1) || false == valid(queue, index2))
			return;
		E e1 = queue.get(index1);
		queue.set(index1, queue.get(index2));
		queue.set(index2, e1);
	}

	private static <E> boolean valid(IQueueContainer<E> queue, int index) {
		if (index < 0 || index >= queue.size())
			return false;
		else
			return true;
	}
}
